package com.hsp.Demo_11_innerclass;

import javafx.application.Application;
import javafx.stage.Stage;

public class Outter08{

        private int size = 1;

        public Inner08 getInstance(){
                return new Inner08();
        }

        //成员内部类：
        public  class Inner08{
                private int inCount = 8;

                private int size = 2;

                public void m1(){
                        System.out.println("Inner08的m1()");
                        System.out.println(size); //返回内部类的size： 2
                        System.out.println(Outter08.this.size); //返回外部类的size：1
                }
        }

        public static void main(String[] args) {
                //创建内部类对象方式一：
                Outter08 outter08 = new Outter08();
                Inner08 inner08 = outter08.new Inner08();
                inner08.m1();
                //方式一可简化为：
                Outter08.Inner08 inner = new  Outter08().new Inner08();
                inner.m1();

                //方式二：在外部类中编写方法，返回内部类对象
                Outter08 outter081 = new Outter08();
                Inner08 instance = outter081.getInstance();
                instance.m1();

        }

}
